Package eu.europa.ec.taxud.cesop.readers
Class CesopXmlReader
- java.lang.Object
-
- eu.europa.ec.taxud.cesop.readers.CesopXmlReader
-
- All Implemented Interfaces:
AutoCloseable
public class CesopXmlReader extends Object implements AutoCloseable
Utils class reading an XML file.
-
-
Constructor Summary
Constructors Constructor Description CesopXmlReader(InputStream inputStream)CesopXmlReader(InputStream inputStream, org.codehaus.stax2.validation.XMLValidationSchema xsd)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()QNamegetStartElementName()Returns the current start tag name.XmlStreamReaderWrappergetXmlStreamReaderWrapper()Returns the XML stream reader wrapper.booleanpositionCursorOnStartElement()Positions the cursor on the next XML start element..booleanpositionCursorOnStartElement(QName qName)Positions the cursor on the next XML start element with specified QName.Optional<Map<String,String>>readNextTagIfEquals(QName qName)Map<String,String>readNextTagIntoMap(QName qName)Read the next tag QName and return a map with all the children values.
-
-
-
Constructor Detail
-
CesopXmlReader
public CesopXmlReader(InputStream inputStream) throws XMLStreamException
- Throws:
XMLStreamException
-
CesopXmlReader
public CesopXmlReader(InputStream inputStream, org.codehaus.stax2.validation.XMLValidationSchema xsd) throws XMLStreamException
Constructor.- Parameters:
inputStream- the input stream. The input stream is not closed byCesopXmlReader.xsd- the xsd- Throws:
XMLStreamException- in case of error while processing the XML content
-
-
Method Detail
-
getStartElementName
public QName getStartElementName() throws XMLStreamException
Returns the current start tag name.- Returns:
- the tag name
- Throws:
XMLStreamException- if the current event type is not a start element
-
positionCursorOnStartElement
public boolean positionCursorOnStartElement() throws XMLStreamExceptionPositions the cursor on the next XML start element.. The next call toXmlStreamReaderWrapper.moveToNextElement()will return the start element.- Returns:
- true if the start element is found, false otherwise
- Throws:
XMLStreamException- in case of error while processing the XML content
-
positionCursorOnStartElement
public boolean positionCursorOnStartElement(QName qName) throws XMLStreamException
Positions the cursor on the next XML start element with specified QName. The next call toXmlStreamReaderWrapper.moveToNextElement()will return the start element.- Parameters:
qName- the name of the start element to search for- Returns:
- true if the start element is found, false otherwise
- Throws:
XMLStreamException- in case of error while processing the XML content
-
readNextTagIfEquals
public Optional<Map<String,String>> readNextTagIfEquals(QName qName) throws XMLStreamException
If the next start element is qName, then returns anOptionalcontainingMapwith all the children values. Otherwise, returns an emptyOptional.- Parameters:
qName- the tag- Returns:
- the map of values
- Throws:
XMLStreamException- in case of error while processing the XML content
-
readNextTagIntoMap
public Map<String,String> readNextTagIntoMap(QName qName) throws XMLStreamException
Read the next tag QName and return a map with all the children values.- Parameters:
qName- the tag- Returns:
- the map of values
- Throws:
XMLStreamException- in case of error while processing the XML content
-
getXmlStreamReaderWrapper
public XmlStreamReaderWrapper getXmlStreamReaderWrapper()
Returns the XML stream reader wrapper.- Returns:
- the XML stream reader wrapper
-
close
public void close() throws XMLStreamException- Specified by:
closein interfaceAutoCloseable- Throws:
XMLStreamException
-
-